library(sf) library(ggplot2) setwd("C:/Users/acer/Desktop/AMAR/MAKTABKHUNEH/codes/IRAN data for R/New folder") getwd() iran <- st_read("irn_admbnda_adm0_unhcr_20190514.shp") ggplot(iran) + geom_sf() province <- st_read("irn_admbnda_adm1_unhcr_20190514.shp") ggplot(province) + geom_sf() city <- st_read("irn_admbnda_adm2_unhcr_20190514.shp") ggplot(city) + geom_sf() Isfahan<-province[province$ADM1_EN=='Isfahan',] ggplot(Isfahan) + geom_sf() Isfahan_Yazd<-province[province$ADM1_EN=='Isfahan'|province$ADM1_EN=='Yazd',] ggplot(Isfahan_Yazd) + geom_sf() Isfahan_city<-city[city$ADM2_EN=='Isfahan',] ggplot(Isfahan_city)+ geom_sf()+theme_bw() Qeshm_city<-city[city$ADM2_EN=="Qeshm",] ggplot(Qeshm_city)+ geom_sf()+theme_bw() bb_Isfahan = st_bbox(Isfahan_city) library(dplyr) library(spData) random_df = tibble( x = runif(n = 10, min = bb_Isfahan[1], max = bb_Isfahan[3]), y = runif(n = 10, min = bb_Isfahan[2], max = bb_Isfahan[4]) ) random_points = random_df %>% st_as_sf(coords = c("x", "y")) %>% # set coordinates st_set_crs(4326) # set geographic CRS ggplot(Isfahan_city)+geom_sf()+geom_point(data=random_df,aes(x,y))+theme_bw() random_df = tibble( x =c( 52.1,52.8,52.6,52.4,52.9,53,52.5), y = c(32.5,32,31.6,32.8,32.4,32.7,32.3) ) random_points = random_df %>% st_as_sf(coords = c("x", "y")) %>% # set coordinates st_set_crs(4326) # set geographic CRS ggplot(Isfahan_city)+geom_sf()+geom_point(data=random_df,aes(x,y))+theme_bw() ##################################################################################################### DF<-cbind(random_df,value=c(15,10,9,10,12,10,8)) DFF<-data.frame(DF) ggplot(Isfahan_city)+geom_sf()+geom_point(data=DFF,aes(x,y,color=value))+theme_bw() ##################################################################################################### DFFF<-data.frame(x =c( 52.1,52.8,52.6,52.4,52.9,53,52.5), y = c(32.5,32,31.6,32.8,32.4,32.7,32.3), value=c(15,10,9,10,12,10,8)) ggplot(Isfahan_city)+geom_sf()+geom_point(data=DFFF,aes(x,y,color=value))+theme_bw()